Repository navigation
Advance #93: snapshot recovery, trusted context, and JSONL ownership - #123
Merged
Merged
Conversation
Driven runs page GET /sessions/{id}/hook-executions after each owned tool
call settles, at idle and before end, and emit one hook_event line per
settled receipt whose call_id belongs to an owned step, correlated with the
owning inputs. Reads are bounded by page count and run start, receipts are
deduplicated with a bounded seen-set, and hook IO or reasons are never
included. Session-scoped receipts without a call_id are not reported. The
flag needs --input-format stream-json.
A child Session's permission/question request now carries root_session_id and root_input_message_ids when every link up to the root is a background subagent Job with one complete, bounded input origin. Scoped attendance, reply validation and Goal unattended-ask timing use that root cohort, so only the bound input client keeps the request waiting; mixed, detached or malformed lineage stamps nothing. OpenAPI and the TS SDK are regenerated.
The root-cohort check accepted any subagent Job row for a parent/child link, so a child whose background Job had settled kept that stale cohort for every later request: a foreground resume (which creates no Job) was stamped with the old input and bound to its client, settling Unattended on that client's release or letting it answer another input's request. A link now proves a cohort only through its running Jobs. A settled or restart-interrupted Job lends nothing; a background resume uses the new running Job's cohort. Regression tests cover settled Jobs, a foreground resume after completion and a restart that interrupts the Job.
The driver now claims a permission/question routed to its Session from a background subagent's child Session when the request's root cohort is entirely its own pending inputs. The line keeps the run's session_id and adds request_session_id, replies post to the child Session, the owning input stays pending while the ask waits, and EOF/end settles it. Another driver of the same Session neither emits nor answers it. A PreToolUse hook "ask" is verified to carry its step cohort and be owned like a direct ask. Fix: replied events carry request_id, not id, so a request answered elsewhere was never dropped from the driver's tracked asks; with asks now holding input slots that would have kept an input pending.
Scoped interruption reported every subagent Job as descendant_job unknown. A running subagent Job whose complete durable cohort lies within the selection now has its handback suppressed and its child subtree stopped through the subtree stop path, when the child is a direct child of the Session and no Job from outside its bounded (256-Session) subtree targets it. The Job counts as cancelled only when the stop acknowledges; mixed, detached or unresolved descendants still report descendant_job unknown. stop_subtree and close_subtree_admissions gain leased variants so the interruption worker, which already holds the lifecycle lease, never re-enters the lifecycle lock behind a pending shutdown.
Update the feature table and local-core guide for settlement-time rule fencing, restart behaviour, delivered/withheld rule inspection, descendant and hook ask ownership, scoped subagent interruption and JSONL hook events; drop stale 'remain open' items and list what is still blocked. Record the reconciliation in implementation.md and the 7.1 task note.
Reverts 6dda753. The flag is delivered by the separate add-exec-hook-events change (PR #132), which covers single-prompt and driven runs, Session-scoped hooks and reused Sessions; keeping both would define the same flag and line twice. The event/apply split in the driver is kept because later request tests use it. Task 6.3, the guides and the implementation log now point to that change.
Add file-copy acceptance tests for a rename restored as delete plus create (owner edits to the new name refuse the whole restore), FIFO/socket entries disclosed as unsupported and never opened, recreated or deleted, and an editor write between two replacements that refuses the rest with a retained journal. Add a real-binary non-Git both-rewind over a rename and delete, undone with sessions checkout --code. Record the 3.4 evidence; platform acceptance stays open.
Lowered-cap HTTP previews refuse code/both with the cap reason while a conversation-only rewind commits; cap-pressure capture retires only an aged, payload-complete restore and leaves within-retention evidence untouched; collection past retention keeps staged-undo and inactive-branch roots and removes an unreferenced manifest only after journals settle. The TUI rewind view renders the cap line and the conversation-only hint. Record 3.3 progress.
Add a debug-only process-cut fixture point between the Session writer commit and the native journal acknowledgement of an ordinary restore (CYBER_TEST_PROCESS_CUT=ordinary-restore-writer-commit; release builds compile it out). Two real-binary branches_cli cases SIGKILL at those boundaries: the service after the writer commit, and a separate maintenance process inside the payload deletion transaction after the first unlink. Both check receipt-only lookup and acknowledgement on restart, unchanged transcript and inference count, surviving later owner edits, and that reclamation resumes the exact frozen plan once. Record the M8 cut matrix in implementation.md mapping each named cut to existing process-death tests, with the remaining gaps marked.
Generalize the parked metadata-retirement child to ordinary restore, paired keep/rollback and prepared cancellation. A separate inert child creates the paired/prepared receipts through a real SIGKILL of the managed restore (partial source exchange, or prepared identities under SQLite writer contention); a second child settles them through the real review/confirm routes, reclaims payloads and parks at the first acknowledgement or claim unlink before being killed. The parents reopen the Store, check the incomplete version-2 plan and its exact missing leaves, resume through periodic maintenance with a no-op repeat, and verify protected Git bytes, Session sequence, later owner links and the same receipt on explicit acknowledgement. Add the support file to the native filter and record the M6/M8 evidence.
Kill a real process after the private claim and acknowledgement stages are flushed and before their no-replace publication. The stage stays byte-identical, no stable claim or acknowledgement appears, and reuse, metadata retirement and worktree removal refuse it as same-owner unknown constructor evidence. A real service kill at the new debug-only checkout-claim-stage-flushed point shows new input refused until the pre-effect preparation is cancelled, with the stage still fenced afterwards. An interrupted cancellation-record stage is never adopted and payload cleanup refuses it. Removal used to report these stages as "Invalid activity identity" or "Unacknowledged checkout construction remains", and `sessions recovery` said only "No retained restore journals." Removal and retirement now name the stage and owner; preparation listing gains `checkout_constructions` from a read-only name inventory (OpenAPI/SDK regenerated), and the CLI text and TUI recovery panel show it with what cancelling does and does not clear. The process-cut fixture moves to cyber-core so the claim constructor can use it. No cleanup authority is added; removing construction evidence needs a separate protocol extension.
The checkout construction name inventory canonicalizes the Session's managed Location, so a Session whose worktree was removed (it keeps worktree_id) made GET /sessions/<id>/rewind/preparations fail, and `sessions recovery` text exited non-zero through its preparation hint. The inventory is advisory: a missing Location yields no names (removal refuses while any stage remains), other inventory errors are logged and yield no names, and the CLI hint is best-effort with a stderr note. The foreign acknowledgement-stage test case used a length-mismatched name and only exercised the malformed path; it now also covers a well-formed stage for another, unacknowledged owner and asserts the listed owner. The claim-stage kill fixture stops the registered service before panicking on timeout. Docs and the spec scenario state which stages recovery clients cannot show (malformed, unlisted owner, cancelled preparation) and that removal and retirement refusals still name them.
The removed-Location journal listing failure was verified against main only by code reading, not a run; say so and record the open product decision. The M8 note still said paired metadata retirement was cut in-process only, which the App SIGKILL cuts have since covered; only paired/prepared payload cleanup is.
Owner decision 2026-11-15: a rule already delivered in the current Context Epoch whose approval is later revoked or re-reviewed, or whose definition changes on disk, is withdrawn at the next request boundary. One rule_withdrawn system marker records it, and view projection replaces its delivered block in earlier tool results with a short notice. Stored results keep their bytes, no Epoch rebuild or compaction is forced, and replay restores the elision after a restart. Delivery now stamps each rule binding with its rendered block (label, length, SHA-256) so the block is elided exactly; redacted or older blocks fall back to the next instruction label or the reminder end.
Owner decision 2026-11-15: an attached stream-json driver does not reconnect across a server restart. When its event stream closes it now writes one error line with code server_lost and a resume object (the Session ID and the cyber exec command that continues it, with --attach when attached and never the password), settles waiting inputs as before and exits 2. The end line keeps its error text and adds error_code and the same resume object. The server-crash test now restarts the server while the driver is still attached through a proxy already pointed at the new server, checks that nothing is resent, and resumes the same Session with the hinted command.
Owner decision 2026-11-15: journal listing for a Session whose Location directory was removed failed with "No such file or directory" because the file-copy namespace key needs the directory identity. When the Location is NotFound, the listing now scans the bounded namespace set and attributes a journal only when its recorded path equals the Location and the namespace key is the digest of that path and the recorded identity. Matching journals are returned with location_removed: true. Nothing is locked, created or deleted; review and restore still fail. The HTTP route, cyber sessions recovery (text marks the rows and drops the review hint) and the TUI recovery panel (marks the rows, Enter starts no discovery) all use it. OpenAPI and the SDK are regenerated.
Owner decision 2026-11-15: managed Git source admission stays off until the native CI matrix is green, and becomes a configuration opt-in after that. It is off today: owned restore admits a Git Location only in the native-git-acceptance build. A new test pins that a default build refuses whatever the configuration says and that snapshots: false refuses in every build. Record the decision and the default in the change notes and docs/rewind.md; the configuration opt-in itself is not implemented.
…ed path Review notes on the non-regular-entry test: rename it to drop "device" (no device node is created) and add a case where a captured a.txt is replaced by a FIFO before restore. That case exposed a partial restore: with a review taken after the replacement, the plan treated the FIFO's "unsupported" capture label like an ignore exclusion, skipped a.txt silently and restored only b.txt. A changed path that the current capture marks unsupported (FIFO, socket, device, link or hard-linked file) is now a conflict and refuses the whole restore; other exclusion kinds keep skipping. The FIFO is never opened, deleted or replaced; both attempts run under a timeout.
…iew) Owner decision 2026-11-15: OpenSpec first, no code. Add the change add-construction-evidence-discard: a two-step owner-only review/confirm command that discards unpublished checkout-claim, acknowledgement and cancellation-record stages of one Session, including those left by a removed Location, with a durable audit receipt written before any unlink. It defines the fencing (idle Session, exclusive activity lifetime lock, no published record, unchanged reviewed identity and digest, local owner only) and what still refuses. Point the managed recovery notes and the externally blocked list at it.
One stage per confirmation, CLI and API first with the TUI showing the command, and failed unlinks retried indefinitely and reported as discard pending while counting toward the snapshot cap.
… proof 90 minutes The three doctor instruction tests matched reported paths with '/', which fails on Windows where the paths use '\'. The macOS Intel snapshot proof took 56 minutes and hit its 60-minute limit twice after the recovery crash-cut cases were added.
This was referenced Nov 16, 2026
Driven exec runs now follow their Session's event stream, so the hook receipts from --include-hook-events (#132) would only reach the instance stream and lose their order against tool_result lines. The Session stream accepts the same opt-in include=hook_receipts and forwards only that Session's own receipt summaries; any other include value is a 400. session_input_event_stream takes the opt-in and the driver passes the flag through, reconciling the receipt listing when the Session goes idle. Specs (add-exec-hook-events), OpenAPI/SDK, guide and changelog updated; the "--include-hook-events is not available yet" note is gone.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances #93.
This branch advances issue #93 across snapshot recovery, trusted rules/context inspection, structured results, and concurrent JSONL execution. It is a shared implementation and review checkpoint: substantial functionality exists, but the remaining acceptance and implementation work below prevents merge readiness. Issue #93 stays open after this PR.
Base:
main. Branch:feat/managed-recovery-owner. Handoff revision:20e0aae0fcf1bc8e4402aea75c80005f5b8f3a18.Implemented behavior
Snapshot recovery and rewind
Trusted rules and context inspection
/context. Inspection reports source origin/status, estimates, pending Epoch/source state and the last prepared request estimate; stored content is hidden by default.Structured results and JSONL ownership
Work other teams can take
These are suggested work areas, not assigned owners. Coordinate ownership in this PR before editing shared runtime/Store interfaces. Branch from this head and target contribution PRs at
feat/managed-recovery-ownerso the combined implementation remains reviewable.crates/cyber-snapshot/src/copy/,crates/cyber-server/src/runtime/snapshot_*,crates/cyber-core/src/worktrees/activity/snapshot/,crates/cyber-store/src/store.rs; tasks 2.4, 3.2–3.4, M2–M8crates/cyber-core/src/rules.rs,crates/cyber-server/src/runtime/instructions*,context_inspection.rs,crates/cyber-app/tests/instructions.rs, TUI context inspection; tasks 4.1–4.4crates/cyber-cli/src/,runtime/input_clients.rs,input_interrupt.rs,input_jobs.rs,requests/input_owners.rs,crates/cyber-cli/tests/exec_stream_input.rs; tasks 6.2–6.4.github/workflows/non-git-snapshot-proof.yml, runtime/CLI/TUI fixtures, tasks 5.4 and 7.1–7.4Use the existing approved OpenSpec design and task IDs. Include meaningful regressions and update evidence with the exact revision, commands, results, skips and retained failure artifacts. Focused increment reviews do not establish whole-branch acceptance. Issue #92 remains a separate workstream; preserve its accepted dependencies without assuming unfinished guarantees or choosing its pending policies.
Verification and limits
Recorded local verification for the latest presence increment:
These are recorded local results, not a fresh full-workspace or cross-platform run. At handoff, GitHub reports 32 successful and 13 failed checks on
20e0aae0. The failures include Linux builds, web, bootstrap, packaged-entry, regression and native snapshot jobs. Their current-head logs have not yet been diagnosed here; do not assume they have the same cause as earlier failures. See the current CI run and the PR Checks tab for the other workflows.Earlier-revision Linux logs showed Ubuntu mirror DNS failures and masked sandbox prerequisite installation. This branch makes prerequisite failure explicit, retains its log and prevents dependent native proof steps from running without successful Linux sandbox setup. A failed prerequisite still fails the job; skipped proof is not accepted as passing.
Authoritative handoff documents
Keep this PR draft until the remaining required behavior, current-source acceptance and consolidated review are complete. Archive the change and reconcile the issue checklist only after accepted delivery.
Continuation, 2026-11-12: rules and context (tasks 4.3–4.4)
1855ae45+, including the Rust 1.99.1 CI pin from Pin Rust 1.99.1 in CI and fix Rust 1.100 lints #129. One conflict, inconfig/load.rs, where both sides added a trust source; both are kept. The 13 failed checks on20e0aae0were all Ubuntu mirror DNS failures (Temporary failure resolving 'azure.archive.ubuntu.com'), not code failures.changed_on_diskper source and achanged_sourcescount. It covers up to 512 files per inspection. A source without complete stamps reports unknown. TUI/contextshows both.next_requestis the stored projection plus the last prepared request's tool schemas. It lists its assumptions: tool schemas from the last request, changed model, pending Epoch rebuild, sources changed on disk, and excluded turn-only instructions. It is absent before the first prepared request. It is an estimate, not an exact projection.Continuation, 2026-11-13: CI fixes and JSONL acceptance (task 6.4)
snapshot_active, soshutdown()could return while a worker still looked busy (intermittent Linux failure ofdisposed_acknowledgement_request_retains_actual_worker_resources_through_shutdown). They now release it last, asSnapshotWorkeralready did.--output-last-message: concurrent writers to one path could fail with "Access is denied" while another rename onto it was in progress; a busy destination is now retried briefly on Windows.reviewed_recovery_code_stages_survive_kill_restage_and_clear_without_adopting_owner_filesalready took 8–9.5 of its 10 minutes on main's Windows runner; it now has 20 there.cyber servethrough a proxy that commits each prompt but drops its responses, ends with the input admitted and the model called once. Removing the driver's retry makes that test fail.refusedalthough the server committed it.Doubly lost JSONL admission (task 6.4)
GET /sessions/{id}/inboxfor that message ID before reporting the input. A held row that is not refused is reportedadmittedand tracked to its result. No row is reportedrefused. If the inbox can't be read, the run ends with exit 2 and an error naming the message ID; it never reports a prompt the server may run asrefused.exec-modespec delta: new scenario "An admission acknowledgement is lost".docs/local-core-guide.mddocuments the behaviour.cyber servethrough a proxy that drops all eight prompt responses:an_admission_whose_retry_is_also_lost_is_confirmed_from_the_inboxandan_unconfirmable_admission_fails_the_run. The first fails, with the input reportedrefused, when the lookup is forced to answer "not committed".-, and--password -Y…was rejected as an unknown flag.cyber exec --password,cyber review --passwordandcyber service password <value>now accept hyphen values, and a parse regression test covers all three. The exec and serve stderr that the test failure now shows is what exposed it. The test server also binds--port 0and reads its URL; that's harmless, but it was not the cause.the server closed the event stream), the waiting input getsnot answered before the run ended, and the restarted server still holds the input (a_server_crash_ends_the_run_explicitly_and_the_restarted_server_keeps_the_input). The driver does not reconnect across a restart; this is documented in the guide.Continuation 2026-11-14: rule fencing, inspection and JSONL ownership (tasks 4.1–4.4, 6.2–6.4, 7.1)
No task was checked off; each still needs native platform acceptance.
Delivered:
a_rule_revoked_while_its_read_settles_is_neither_delivered_nor_consumed).*_restarttests incrates/cyber-app/tests/instructions.rs)./contextandGET /sessions/{id}/contextlist up to 128 delivered rules withcurrent/changed/revoked/unknownapproval, and withheld rule definitions by reason (trust_held,read_denied,invalid_frontmatter,compat_disabled,bound_exceeded), without opening them. OpenAPI/SDK regenerated.instructionscheck counts scoped rules without adding them to the baseline and lists withheld definitions by reason, honouringcompat.claude.last_prepared_requestrebuilt exactly from the provider's actual request body.error/result/enderror fields pass through the built-in redactor.--include-hook-events(6.3):hook_eventlines from durable hook receipts for tool calls of the driver's own prompts.root_session_id/root_input_message_idswhen every link is a running background subagent Job; the driver claims, answers and drains those andPreToolUsehook asks. Bug fixed with a regression test:*.repliedevents carryrequest_id, so a request answered elsewhere was never dropped from the driver's asks.interruptalso stops an owned background subagent subtree; a mixed-cohort child stays running and is reported unknown.docs/features.mdanddocs/local-core-guide.mdreconciled with the above;docs/cli.md,sdk/openapi.jsonand the generated SDK verified current.Still open in code: withdrawing a rule already delivered in the current Epoch after revocation or change (inspection only reports it); withheld non-rule instruction files as typed entries; foreground-subagent ownership; acknowledged interruption of a subagent with an in-flight tool call; Session-scoped and descendant hook receipts; user-configured redaction patterns on JSONL lines; the raw provider message in
session.step.failed.Externally blocked:
Recovery continuation 2026-11-14 (2)
Issue #93 managed-recovery increments. Evidence is local macOS arm64 only; no task was checked off and no platform acceptance is claimed.
Delivered:
d24eb6a1): a non-Git rename restored as delete plus create (owner edit to the new name refuses the restore; unrelated edits kept), FIFO and Unix-socket entries reportedunsupportedand never touched, an editor write between two replacements refuses the rest and keeps the edit with a retained journal, and a real-binarybothrewind over a rename/delete undone withsessions checkout --code.f8c4d7e0): App over HTTP refusescode/bothpreviews over a lowered cap with the cap reason and still commits a conversation-only rewind; the TUI shows the cap line. Cap-pressure capture retires only aged, payload-complete restores; collection keeps staged-undo and inactive-branch roots.14cb0115): real SIGKILL after the Session writer commit and before the journal acknowledgement (debug-only fixture point, compiled out of release), and inside payload reclamation after the first unlink; both resume without replay, transcript movement or inference. implementation.md now has a per-cut evidence table with gaps marked.abcfb0f5): App SIGKILL during paired keep/rollback and prepared-cancellation metadata retirement; maintenance completes the same frozen plan and lookup returns the same receipt.0a759e01,54e13a97): kills between a flushed checkout claim/acknowledgement stage and its publication leave the stage fenced (same-owner unknown constructor) and listed by recovery clients; preparation listing now survives a removed managed worktree (bug fix with regression test, the construction inventory is advisory).0a71bba1): the removed-Location claim is narrowed to code reading, and the stale M8 note on metadata retirement is corrected.Note: the
--include-hook-eventsbullet in the previous section is outdated;c0d44613reverted it here in favour of the add-exec-hook-events change (PR #132).Still open (2.4, 3.2–3.4, M2–M8 stay unchecked):
Decisions needed from the owner:
GET /sessions/{id}/rewind/recovery(andcyber sessions recovery) should report for a Session whose Location was removed. Today it fails with "No such file or directory"; by code readingmainfails the same way, but this was not reproduced by a run onmain.Owner decisions 2026-11-15
Each decision is recorded in
openspec/changes/complete-daily-coding-surfaces(design.md "Owner decisions 2026-11-15", implementation.md section of the same name, tasks.md) and removed from the "Externally blocked" list; the open questions above about the removed-Location listing, managed Git admission and construction-evidence cleanup are resolved as below. Local macOS arm64 results only.7a80f98e. At the next request boundary onerule_withdrawnsystem marker records each delivered rule whose approval was revoked or whose definition changed; from that request on its delivered block is elided from earlier tool results (exact match by recorded label/length/SHA-256, fallback to the next label). Stored results are unchanged, no Epoch rebuild or compaction, survives restart. Tests:a_revoked_delivered_rule_is_elided_from_later_requests_and_after_restart,a_changed_delivered_rule_is_elided_from_the_next_request(cyber-appinstructions), unit tests inruntime::rule_withdrawal.e4419960. The driver emits anerrorline withcode: "server_lost"andresume(session_idand thecyber exec … --session <id>command, never the password), exits 2, andendcarrieserror_code/resume. Test:a_server_restart_under_an_attached_driver_ends_with_a_resume_hint_and_keeps_the_input(realcyber servekilled and restarted while the driver is attached through a proxy already pointed at the new server; the hint resumes the same Session).405d3f95. Instead of "No such file or directory", journals recorded for the removed path are listed withlocation_removed: true(HTTP route,cyber sessions recovery, TUI panel); nothing is locked or deleted and review still fails. OpenAPI/SDK regenerated. Tests:removed_location_lists_its_retained_journals_read_only(cyber-snapshot),removed_location_recovery_lists_retained_journals_as_orphaned(branches_cli), TUIa_removed_location_journal_is_listed_read_only.ec6b2996. Verified off (only thenative-git-acceptancebuild admits it); pinned bymanaged_git_source_admission_is_off_by_default. The configuration opt-in itself is not implemented.51c0c56e. Test renamed tofifo_and_socket_entries_are_disclosed_unsupported_and_never_restored_or_deleted; newa_captured_file_replaced_by_a_fifo_refuses_restore_and_keeps_the_fifoexposed a partial restore (the FIFO'sunsupportedlabel was skipped like an ignore and onlyb.txtwas restored). Fixed: anunsupportedcurrent entry at a changed path is now a conflict and the whole restore refuses; the FIFO is never opened, deleted or replaced.ba659e34. New changeopenspec/changes/add-construction-evidence-discard(awaiting owner review): owner-only review/confirm discard of unpublished construction stages, including removed-Location evidence, with an audit receipt, fencing rules and the list of what still refuses.Verification:
cargo fmt --check; Clippy-D warnings --all-targetsfor cyber-server, cyber-app, cyber-cli (also withnative-git-acceptance), cyber-tui, cyber-snapshot; nextestci: cyber-server lib +http(571),context_compaction, cyber-appinstructions(31) andsnapshot_reclamation(48), cyber-cliexec_stream_input(34) andbranches_cliwithnative-git-acceptance(33), cyber-tui lib (686), cyber-snapshot all (214); strict OpenSpec (104 items), spec lint 0 errors, spec inventory, SDK--check, OpenAPI current,docs/cli.mdunchanged.